﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Net5ApiAndEfMySql.API.Common;
using Net5ApiAndEfMySql.DtoModel.SystemAdmin;
using Net5ApiAndEfMySql.IService;
using Net5ApiAndEfMySql.IService.SystemAdmin;
using Net5CommonLib.SystemLib.Common;

namespace Net5ApiAndEfMySql.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ServiceFilter(typeof(UserTokenVerificationAttribute))] //使用ServiceFilter会自动将依赖注入注入到过滤器中
    [ApiController]
    public class BaseApiController : ControllerBase
    {
        public OperatorDto LoginUser
        {
            get
            {
                return DiManager.GetDiObjScoped<IOperatorService>().GetLoginUserByToken(Token);
            }
        }

        public string Token
        {
            get
            {
                return HttpContextManager.GetHeaderPara("X-Token");
            }
        }
    }
}
